package com.futureCloudMOM.controller.core.web.wms;

import com.futureCloudMOM.common.annotation.Log;
import com.futureCloudMOM.common.core.domain.AjaxResult;
import com.futureCloudMOM.common.enums.BusinessType;
import com.futureCloudMOM.controller.core.controller.BaseApiController;
import com.futureCloudMOM.core.domain.WmsInvoiceMain;
import com.futureCloudMOM.core.service.WmsInvoiceMainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 文件名 WmsInvoiceMainController
 *
 * @since 2023/6/7 9:17
 */
@Api(tags = "业务订单主表")
@RestController
@RequestMapping("wms/invoice_main")
public class WmsInvoiceMainController extends BaseApiController<WmsInvoiceMain, WmsInvoiceMain, WmsInvoiceMainService> {

    public WmsInvoiceMainController(WmsInvoiceMainService service) {
        super(service);
    }


    @ApiOperation(value = "业务订单主子表的新增")
    @Log(title = "业务订单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody WmsInvoiceMain wmsInvoiceMain) {
        return AjaxResult.success(service.add(wmsInvoiceMain));
    }

    @ApiOperation(value = "业务订单主子表的编辑")
    @Log(title = "业务订单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@Validated @RequestBody WmsInvoiceMain wmsInvoiceMain) {
        service.edit(wmsInvoiceMain);
        return AjaxResult.success();
    }

    @Log(title = "订单提交")
    @ApiOperation("订单提交")
    @GetMapping("/submit/{id}")
    public AjaxResult submit(@PathVariable("id") Long id){
        service.submit(id);
        return success();
    }

    @ApiOperation(value = "订单审核")
    @Log(title = "订单审核")
    @GetMapping("/orderReview/{id}")
    public AjaxResult orderReview(@PathVariable("id") Long id) {
        service.orderReview(id);
        return success();
    }

    @ApiOperation(value = "订单反审核")
    @Log(title = "订单反审核")
    @GetMapping("/orderDeApproval/{id}")
    public AjaxResult orderDeApproval(@PathVariable("id") Long id) {
        service.orderDeApproval(id);
        return success();
    }

    @ApiOperation(value = "订单作废")
    @Log(title = "业务订单作废")
    @GetMapping("/cancellation/{id}")
    public AjaxResult cancellation(@PathVariable("id") Long id) {
        service.cancellation(id);
        return success();
    }

    @ApiOperation(value = "强制结案")
    @Log(title = "业务订单强制结案")
    @GetMapping("/forcedClose/{id}")
    public AjaxResult forcedClose(@PathVariable("id") Long id) {
        service.forcedClose(id);
        return success();
    }

    /**
     * 生产领料
     */
    @Log(title = "生产领料订单提交并备货")
    @ApiOperation("生产领料订单提交并备货")
    @GetMapping("/submitAndStockMarker/{id}")
    public AjaxResult submitAndStockMarker(@PathVariable("id") Long id){
        service.submitAndStockMarker(id);
        return success();
    }


}
